package cn.iocoder.yudao.module.api.pay.wallet.enums;

import cn.iocoder.yudao.framework.business.basic.enums.EnumValuable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 钱包交易业务分类
 *
 * @author jason
 * @author 山野羡民
 */
@AllArgsConstructor
@Getter
public enum PayWalletBizTypeEnum implements EnumValuable {

    UNKNOWN(0, "未知"),

    RECHARGE(1, "充值"),
    RECHARGE_REFUND(2, "充值退款"),

    PAYMENT(3, "支付"),
    PAYMENT_REFUND(4, "支付退款"),

    UPDATE_BALANCE(5, "系统调整"),

    COMMISSION_UNFREEZE(8, "佣金结算"),
    COMMISSION_CANCEL(9, "佣金取消"),

    REVENUE_UNFREEZE(14, "营业收入"),
    REVENUE_CANCEL(15, "营业收入取消"),
    REVENUE_GIFT(17, "赠品分账"),

    CASH_OUT_APPLY(6, "提现申请"),
    CASH_OUT_CLOSED(7, "提现失败"),

    CRYPTOCURRENCY_ORIGIN_TO_MONEY(10, "联盟豆兑现"),
    BONUS_TO_MONEY(11, "分红兑现"),
    INTEREST_TO_MONEY(12, "消费金兑现"),
    CRYPTOCURRENCY_INCREMENT_TO_MONEY(13, "收益豆兑现"),

    TRANSFER(16, "转账"),
    ;

    @EnumValue
    private final Integer value;
    private final String name;

    public static PayWalletBizTypeEnum valueOf(Integer value) {
        return Arrays.stream(values())
                .filter(item -> Objects.equals(item.getValue(), value))
                .findFirst()
                .orElse(UNKNOWN);
    }

}
